package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: adol book
 * Date: 2022-05-03
 * Time: 15:21
 */

class Fruit{
    public String name;
    public String corlor;

    public Fruit(String name, String corlor) {
        this.name = name;
        this.corlor = corlor;
    }
    public void corlor(){
        System.out.println(this.name+"是"+this.corlor);
    }
    public void eat(){
        System.out.println(this.name+"好吃");
    }
}
class Apple extends Fruit{
    public Apple(String name, String corlor) {
        super(name, corlor);
    }
}
class Pesr extends Fruit{
    public Pesr(String name, String corlor) {
        super(name, corlor);
    }
}
public class TestDemo {
    public static Fruit sun(String name){
        if("苹果" == name){
            return new Apple("苹果","红色");
        }else if("梨" == name){
            return new Pesr("梨","黄色");
        }else {
            return null;
        }
    }
    public static void FUNC(Fruit fruit){
        fruit.eat();
    }
    public static void main(String[] args) {
        Apple apple = new Apple("xixi","red");
        FUNC(apple);
//        String t = "苹果";
//        Fruit fruit =  sun(t);
//        fruit.eat();
//        Fruit fruit = new Apple("苹果","红色");
//        fruit.eat();
//        fruit.corlor();

    }
}
